package top.tenebrous.termbor.rpc.protocol.enums;

import lombok.Getter;

/**
 * @program: termbor-rpc
 * @description:
 * @author: yazhang6
 * @create: 2024-05-21 09:19
 **/
@Getter
public enum RpcType {

    // 请求消息
    REQUEST(1),
    // 响应消息
    RESPONSE(2),
    // 心跳消息
//    HEARTBEAT(3),

    HEARTBEAT_FROM_CONSUMER(3),
    HEARTBEAT_TO_CONSUMER(4),
    HEARTBEAT_FROM_PROVIDER(5),
    HEARTBEAT_TO_PROVIDER(6);

    private final int type;

    RpcType(int type) {
        this.type = type;
    }

    public static RpcType findByType(byte msgType) {
        for (RpcType value : values()) {
            if (msgType == value.type) {
                return value;
            }
        }
        return null;
    }
}
